<?php

function smarty_function_innova_entrypoint($params, &$smarty) {

  
    //Get QString from url
    $explodeQString = explode("&", $smarty->qstring);
    
    //Get this language
    $language = $params["language"];
    
    //Get all language
    $langArray = LanguageUtil::getInstalledLanguages(); 
    
    $arraySearch = NULL;
    $searchResultArray = array();    
    $searchText = "";
    foreach($langArray as $key=>$item){   
      $searchText = "newlang=".$key;
      $inArray = in_array($searchText, $explodeQString);       
      if($inArray){
        $arraySearch = array_search($searchText, $explodeQString);        
        unset($explodeQString[$arraySearch]);
        break;
      } 
    }
    
  $explodeQString[$arraySearch] = "newlang=".$language;    
  $implodeQString = "index.php?".implode("&", $explodeQString);  
/*  
  $implodeQString  = "";
  if($arraySearch > -1 && isset($arraySearch)){
   $implodeQString = "index.php?".implode("&", $explodeQString);
  }
*/  
  return $implodeQString;

  
}